﻿using System;
using System.ComponentModel;
using System.Xml.Serialization;
namespace Landpy.CruiseControlNet.FacadeInterface.ConfigurationModule
{
    public abstract class Permission : IPrimaryKey
    {
        [Browsable(false)]
        [XmlIgnore]
        public Guid Id { get; private set; }

        [Category("Advanced")]
        [Description("The type of the permission.")]
        [XmlIgnore]
        public PermissionType Type { get; private set; }

        [Category("Basic")]
        [Description("The right to change the configuration of projects.")]
        [XmlAttribute("changeProject")]
        public PermissionCategoryType ChangeProject { get; set; }

        [Category("Basic")]
        [Description("The default right to use.")]
        [XmlAttribute("defaultRight")]
        public PermissionCategoryType DefaultRight { get; set; }

        [Category("Basic")]
        [Description("The right for force or abort builds.")]
        [XmlAttribute("forceBuild")]
        public PermissionCategoryType ForceBuild { get; set; }

        [Category("Basic")]
        [Description("The right to modify security.")]
        [XmlAttribute("modifySecurity")]
        public PermissionCategoryType ModifySecurity { get; set; }

        [Category("Basic")]
        [Description("The identifier of the referenced permission.")]
        [XmlAttribute("ref")]
        public string Ref { get; set; }

        [Category("Basic")]
        [Description("The right to send messages.")]
        [XmlAttribute("sendMessage")]
        public PermissionCategoryType SendMessage { get; set; }

        [Category("Basic")]
        [Description("The right to stop and start projects.")]
        [XmlAttribute("startProject")]
        public PermissionCategoryType StartProject { get; set; }

        [Category("Basic")]
        [Description("The user login name.")]
        [XmlAttribute("viewConfiguration")]
        public PermissionCategoryType ViewConfiguration { get; set; }

        [Category("Basic")]
        [Description("The user login name.")]
        [XmlAttribute("viewProject")]
        public PermissionCategoryType ViewProject { get; set; }

        [Category("Basic")]
        [Description("The user login name.")]
        [XmlAttribute("viewSecurity")]
        public PermissionCategoryType ViewSecurity { get; set; }

        protected Permission(PermissionType permissionType)
        {
            this.Type = permissionType;
            this.Id = Guid.NewGuid();
        }
    }
}
